﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;

namespace Shopping_List
{
    /// <summary>
    /// Shopping List
    /// Version 4.0.0
    /// A Application for creating Shopping Lists
    /// </summary>
    public partial class MainForm : Form
    {
        #region Variables!
        String filename                = "Untitled";
        String[] OptionValues          = {"RecentCount","AutoSort","ShowCategories","ExitSearch", "AutoSearch"};
        int RecentItemCount            = 10;
        List<String> ItemList_Cats      = new List<string>();
            
        #region File Paths
            public String DatabaseFileName = (Application.CommonAppDataPath + "\\Database.SLIST");
            String OptionsFileName         = (Application.CommonAppDataPath + "\\Options.SLIST");
            String RecentFileName          = (Application.CommonAppDataPath + "\\Recent.SLIST");
            public String FavesFileName    = (Application.CommonAppDataPath + "\\Faves.SLIST");
            #endregion
                    
        #region Cookies
            public String DatabaseCookie   = "Slist_Dat_V.1.1";
            const String OptionsCookie     = "Slist_Opt_V.1.1";
            const String RecentCookie      = "Slist_Rec_V.1.0";
            public String FavesCookie      = "Slist_Fav_V.1.0";
            const String SaveFileCookie    = "Slist_Sav_V.1.0";
            #endregion
            
        #region Colors
            public Color ButtonPlain       = Color.DarkGray;
            public Color Button_OverGroup  = Color.Silver;
            public Color Button_OverButton = Color.WhiteSmoke;
            public Color ButtonDown        = Color.Black;
            public Color ButtonActivated   = Color.Gray;
            public Color MenuButtonUp      = Color.White;
            public Color MenuButtonDown    = Color.Black;
            #endregion
        #endregion

        #region Public Functions
        public void Load_Database(TreeView loadto)
        {
            do{
                System.Diagnostics.Debug.Print(DatabaseFileName);
                if (File.Exists(DatabaseFileName) == false)
                {
                    var result = MessageBox.Show("No Database File!", "Shopping List", MessageBoxButtons.AbortRetryIgnore);
                    if (result == System.Windows.Forms.DialogResult.Abort)
                    {
                        Application.Exit();
                    }
                    else if (result == System.Windows.Forms.DialogResult.Ignore)
                    {
                        break;
                    }
                }
          } while(1 < 0);
            StreamReader datareader = new StreamReader(DatabaseFileName);
            do{
                try
                {
                    if (datareader.ReadLine() == DatabaseCookie)
                    {
                        loadto.Nodes.Clear();
                        ItemList.Items.Clear();
                        String CatName = "";
                        String Result = "";
                        while (datareader.EndOfStream == false)
                        {
                            CatName = datareader.ReadLine();
                            loadto.Nodes.Add(CatName);
                            Result = datareader.ReadLine();
                            while (Result != "?END")
                            {
                                ItemList.Items.Add(Result);
                                loadto.Nodes[loadto.Nodes.Count - 1].Nodes.Add(Result);
                                ItemList_Cats.Add(CatName);
                                Result = datareader.ReadLine();
                            }
                        }
                        datareader.Close();
                    }
                    else
                    {
                        if (MessageBox.Show("Invalid Database File!", "Shopping List", MessageBoxButtons.OK, MessageBoxIcon.Error) == System.Windows.Forms.DialogResult.OK)
                        {
                            return;
                        }
                    }
                }
                catch
                {
                    var result = MessageBox.Show("An Error Occured!", "Shopping List", MessageBoxButtons.AbortRetryIgnore);
                    if (result == System.Windows.Forms.DialogResult.Abort)
                    {
                        Application.Exit();
                    }
                    else if (result == System.Windows.Forms.DialogResult.Ignore)
                    {
                        break;
                    }
                }
                finally
                {
                    datareader.Close();
                }
            } while(1 < 0);
        }

        void ParseLine(StreamReader reader)
        {
            Boolean flag = false;
            String name = "";
            String value = "";
            foreach(Char currentbyte in reader.ReadLine())
            {
                if (currentbyte == '=')
                {
                    flag = true;
                }
                else
                {
                    if (flag == true)
                    {
                        value += currentbyte.ToString();
                    }
                    else
                    {
                        name += currentbyte.ToString();
                    }
                }
            }
            ApplyLine(GetOptionValue(name), value);    
        }
        
        int GetOptionValue(String OptionName)
        {
            int i = 0;
            foreach (String item in OptionValues)
            {                
                if (item == OptionName)
                {
                    break;
                }
                i++;
            }
            return i;
        }

        public void Load_Options()
        {
            StreamReader reader = new StreamReader(OptionsFileName);
            try
            {
                if (reader.ReadLine() == OptionsCookie)
                {
                    while (!reader.EndOfStream)
                    {
                        ParseLine(reader);
                    }
                }
                reader.Close();
            }
            catch
            {
                MessageBox.Show("Options Load Unsuccessful", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                reader.Close();
            }
        }

        Boolean ApplyLine(int intvalue, String Value)
        {
            switch (intvalue)
            {
                case 0: //RecentCount
                    RecentItemCount = Convert.ToInt32(Value);
                    break;
                case 1: //AutoSort
                    AutoSortDatabaseMenuItem.Checked = Convert.ToBoolean(Value);
                    break;
                case 2: //ShowCategories
                    ShowCatagoriesMenuItem.Checked   = Convert.ToBoolean(Value);
                    break;
                case 3: //ExitSearch
                    ExitSearchOnAddMenuItem.Checked  = Convert.ToBoolean(Value);
                    break;
                case 4: //AutoSearch
                    AutosearchMenuItem.Checked       = Convert.ToBoolean(Value);
                    break;
                default:
                    return false;
            }
            return true;
        }

        String GetValue(int intvalue)
        {
            switch (intvalue)
            {
                case 0: //RecentCount
                    return RecentItemCount.ToString();
                case 1: //AutoSort
                    return AutoSortDatabaseMenuItem.Checked.ToString();
                case 2: //ShowCategories
                    return ShowCatagoriesMenuItem.Checked.ToString();
                case 3: //ExitSearch
                    return ExitSearchOnAddMenuItem.Checked.ToString();
                case 4: //AutoSearch
                    return AutosearchMenuItem.Checked.ToString();
                default:
                    return null;
            }
        }

        public void Save_Options()
        {
            StreamWriter writer = new StreamWriter(OptionsFileName);
            try
            {
                writer.WriteLine(OptionsCookie);
                int i = 0;
                foreach (String Option in OptionValues)
                {
                    writer.WriteLine(Option + '=' + GetValue(i));
                    i++;
                }
            }
            catch
            {
                MessageBox.Show("Options Save Unsuccessful", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                writer.Close();
            }
        }

        public void LoadList(String File, String Cookie, ListBox List)
        {
            try
            {
                StreamReader reader = new StreamReader(File);
                if (reader.ReadLine() == Cookie)
                {
                    while (!reader.EndOfStream)
                    {
                        List.Items.Add(reader.ReadLine());
                    }
                }
                else
                {
                    MessageBox.Show("Invalid File!");
                }
                reader.Close();
            }
            catch
            {
                MessageBox.Show("An Error Occured");
            }
        }

        public void Reset()
        {
            RecoverLostFiles();
            Load_Options();
            Load_Database(ItemTree);
        }

        public void RecoverLostFiles()
        {
            if(File.Exists(DatabaseFileName) == false)
            {
                StreamWriter writer = new StreamWriter(DatabaseFileName);
                writer.WriteLine(DatabaseCookie);
                writer.Close();
            }
            if (File.Exists(OptionsFileName) == false)
            {
                StreamWriter writer = new StreamWriter(OptionsFileName);
                writer.WriteLine(OptionsCookie);
                writer.Close();
            }
            if (File.Exists(RecentFileName) == false)
            {
                StreamWriter writer = new StreamWriter(RecentFileName);
                writer.WriteLine(RecentCookie);
                writer.Close();
            }
            if (File.Exists(FavesFileName) == false)
            {
                StreamWriter writer = new StreamWriter(FavesFileName);
                writer.WriteLine(FavesCookie);
                writer.Close();
            }
        }

        public void AddItemToList()
        {
            if (ItemList.Visible == true)
            {
                if (FinalBox.SelectedIndex > -1)
                {
                    FinalBox.Items.Add(ItemList.SelectedItem);
                }
                else
                {
                    MessageBox.Show("You have nothing selected");
                }
            }
            else
            {
                if (ItemTree.SelectedNode.Level == 1 & ItemTree.SelectedNode.Index > -1)
                {
                    FinalBox.Items.Add(ItemTree.SelectedNode.Parent.Text + "-" + ItemTree.SelectedNode.Text);
                }
                else
                {
                    MessageBox.Show("Can't add that!");
                }
            }
        }
        #endregion

        #region application startup
        public MainForm()
        {
            InitializeComponent();
        }

        private void MainForm_Load(object sender, EventArgs e)
        {
            Reset();
        }
        #endregion

        #region Main Menu
        private void OptionChange(object sender, EventArgs e)
        {
            Save_Options();
        }
            #region File Menu
            private void NewMenuItem_Click(object sender, EventArgs e)
            {
                FinalBox.Items.Clear();
            }

            private void OpenMenuItem_Click(object sender, EventArgs e)
            {
                if (OpenDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    FinalBox.Items.Clear();
                    LoadList(OpenDialog.FileName, SaveFileCookie, FinalBox);
                }
            }

            void DoSave()
            {
                StreamWriter writer = new StreamWriter(filename);
                writer.WriteLine(SaveFileCookie);
                foreach (String item in FinalBox.Items)
                {
                    writer.WriteLine(item);
                }
                writer.Close();
            }

            private void SaveMenuItem_Click(object sender, EventArgs e)
            {
                if (filename == "Untitled")
                {
                    if (SaveDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        filename = SaveDialog.FileName;
                        DoSave();
                    }
                }
                else
                {
                    DoSave();
                }
            }

            private void SaveToExtendList_Click(object sender, EventArgs e)
            {
                //-----------------Insert Code Here---------------
            }

            private void saveAsMenuItem_Click(object sender, EventArgs e)
            {
                if (SaveDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    filename = SaveDialog.FileName;
                    DoSave();
                }
            }

            private void PrintMenuItem_Click(object sender, EventArgs e)
            {
                //-----------------Insert Code Here---------------
            }

            private void ExitMenuItem_Click(object sender, EventArgs e)
            {
                Application.Exit();
            }
            #endregion

            #region Window Menu
            private void ClassicListMenuItem_Click(object sender, EventArgs e)
            {
                classic classic = new classic();
                classic.ShowDialog();
            }

            private void StatsMenuItem_Click(object sender, EventArgs e)
            {
                Forms.Stats stats = new Forms.Stats();
                stats.ShowDialog();
            }
            #endregion
        
            #region Tools Menu
            private void ResetMenuItem_Click(object sender, EventArgs e)
            {
                //-----------------Insert Code Here---------------
            }

            private void CopyToClipboardMenuItem_Click(object sender, EventArgs e)
            {
                String TmpString = "";
                foreach(String item in FinalBox.Items)
                {
                    TmpString += item  + "\n";
                }
                Clipboard.SetText(TmpString);
            }

            private void RefreshMenuItem_Click(object sender, EventArgs e)
            {
                Reset();
            }
            #endregion

            #region Options Menu
            private void SetRecentItemCountMenuItem_Click(object sender, EventArgs e)
            {
                Forms.Text textinput = new Forms.Text();
                textinput.LoadInput(3);
                if (textinput.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    RecentItemCount = Convert.ToInt32(textinput.Result);
                    Save_Options();
                }
            }
            #endregion
        #endregion

        #region Bottom Panel

            #region Step 1
            private void ManageCategories_Click(object sender, EventArgs e)
            {
                Forms.DataEdit dataedit = new Forms.DataEdit();
                dataedit.ShowDialog();
                Reset();
            }
            #endregion
            
            #region Step 2
            private void AddToList_Click(object sender, EventArgs e)
            {
                AddItemToList();
            }

            private void AddFromText_Click(object sender, EventArgs e)
            {
                Forms.Text textinput = new Forms.Text();
                textinput.LoadInput(1);
                if (textinput.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    FinalBox.Items.Add(textinput.Result);
                }
                if (FinalBox.Items.Count == 1)
                {
                    Remove.BackColor = ButtonDown;
                }
            }

            private void Rename_Click(object sender, EventArgs e)
            {
                Forms.Text textinput = new Forms.Text();
                textinput.LoadInput(1);
                if (textinput.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    int indexat = FinalBox.SelectedIndex;
                    FinalBox.Items.Insert(indexat, textinput.Result);
                    FinalBox.Items.RemoveAt(indexat + 1);
                    FinalBox.SelectedIndex = indexat;
                }
            }

            private void ShowFaves_Click(object sender, EventArgs e)
            {
                if (ShowFavesForeImage.Image == Properties.Resources.DownArrow)
                {
                    if (ShowCatagoriesMenuItem.Checked)
                    {
                        ItemList.Hide();
                    }
                    else
                    {
                        Load_Database(ItemTree);
                        ItemList.Show();
                    }
                    ShowFaves.BackColor = ButtonPlain;
                    ShowFavesForeImage.BackColor = ButtonPlain;
                    ShowFavesForeImage.Image = Properties.Resources.UpArrow;
                }
                else
                {
                    ShowFaves.BackColor = ButtonActivated;
                    ShowFavesForeImage.BackColor = ButtonActivated;
                    ItemList.Visible = true;
                    ItemList.Items.Clear();
                    LoadList(FavesFileName, FavesCookie, ItemList);
                    ShowFavesForeImage.Image = Properties.Resources.DownArrow;
                    ShowRecentForeImage.Image = Properties.Resources.UpArrow;
                }
            }

            private void ShowRecent_Click(object sender, EventArgs e)
            {
                if (ShowRecentForeImage.Image == Properties.Resources.DownArrow)
                {
                    if (ShowCatagoriesMenuItem.Checked)
                    {
                        ItemList.Hide();
                    }
                    else
                    {
                        Load_Database(ItemTree);
                        ItemList.Show();
                    }
                    ShowRecent.BackColor = ButtonPlain;
                    ShowRecentForeImage.BackColor = ButtonPlain;
                    ShowRecentForeImage.Image = Properties.Resources.UpArrow;
                }
                else
                {
                    ItemList.Show();
                    LoadList(RecentFileName, RecentCookie, ItemList);
                    ShowRecent.BackColor = ButtonActivated;
                    ShowRecentForeImage.BackColor = ButtonActivated;
                    ShowRecentForeImage.Image = Properties.Resources.DownArrow;
                    ShowFavesForeImage.Image = Properties.Resources.UpArrow;
                }
            }


        
            private void AddFromDatabaseExtend_Click(object sender, EventArgs e)
            {
                //-----------------Insert Code Here---------------
            }

            private void Remove_Click(object sender, EventArgs e)
            {
                FinalBox.Items.Remove(FinalBox.SelectedItem);
            }
            #endregion

            //Step 3 in File Menu Click Events

            //Step 4 in File Menu Click Events
        private void AboutButton_Click(object sender, EventArgs e)
        {
            Forms.About AboutPage = new Forms.About();
            AboutPage.ShowDialog();
        }
        #endregion

        #region Special Stuff
        
        #region Menu Bar
        private void FileMenu_DropDownOpened(object sender, EventArgs e)
        {
            FileMenu.ForeColor = MenuButtonDown;
        }

        private void FileMenu_DropDownClosed(object sender, EventArgs e)
        {
            FileMenu.ForeColor = MenuButtonUp;
        }

        private void WindowMenu_DropDownOpened(object sender, EventArgs e)
        {
            WindowMenu.ForeColor = MenuButtonDown;
        }

        private void WindowMenu_DropDownClosed(object sender, EventArgs e)
        {
            WindowMenu.ForeColor = MenuButtonUp;
        }

        private void ToolsMenu_DropDownOpened(object sender, EventArgs e)
        {
            ToolsMenu.ForeColor = MenuButtonDown;
        }

        private void ToolsMenu_DropDownClosed(object sender, EventArgs e)
        {
            ToolsMenu.ForeColor = MenuButtonUp;
        }

        private void ListMenu_DropDownOpened(object sender, EventArgs e)
        {
            ListMenu.ForeColor = MenuButtonDown;
        }

        private void ListMenu_DropDownClosed(object sender, EventArgs e)
        {
            ListMenu.ForeColor = MenuButtonUp;
        }

        private void OptionsMenu_DropDownClosed(object sender, EventArgs e)
        {
            OptionsMenu.ForeColor = MenuButtonUp;
        }

        private void OptionsMenu_DropDownOpened(object sender, EventArgs e)
        {
            OptionsMenu.ForeColor = MenuButtonDown;
        }
        #endregion

        #region Bottom Bar
        #region Step 1
        private void ManageCategories_MouseEnter(object sender, EventArgs e)
            {
                ManageCategories.BackColor = Button_OverButton;
                Step1Label.BackColor       = Button_OverGroup;
            }

            private void ManageCategories_MouseLeave(object sender, EventArgs e)
            {
                ManageCategories.BackColor = ButtonPlain;
                Step1Label.BackColor       = ButtonPlain;
            }

            private void ManageCategories_MouseDown(object sender, MouseEventArgs e)
            {
                ManageCategories.BackColor = ButtonDown;
            }

            private void ManageCategories_MouseUp(object sender, MouseEventArgs e)
            {
                ManageCategories.BackColor = Button_OverButton;
            }
            #endregion

            #region Step 2
            private void Step2_On()
            {
                AddToList.BackColor             = Button_OverGroup;
                AddFromText.BackColor           = Button_OverGroup;
                if (Rename.Enabled == true)
                {
                    Rename.BackColor = Button_OverGroup;
                }
                else
                {
                    Rename.BackColor = ButtonActivated;
                }
                ShowFaves.BackColor = Button_OverGroup;
                ShowFavesForeImage.BackColor = Button_OverGroup;
                ShowRecent.BackColor = Button_OverGroup;
                ShowRecentForeImage.BackColor = Button_OverGroup;
                AddFromDatabaseExtend.BackColor = Button_OverGroup;
                if (Remove.Enabled == true)
                {
                    Remove.BackColor            = Button_OverGroup;
                }
                else
                {
                    Remove.BackColor            = ButtonActivated;
                }
                Step2Label.BackColor            = Button_OverGroup;
            }

            private void MouseLeavesGroup2(object sender, EventArgs e)
            {
                AddToList.BackColor             = ButtonPlain;
                AddFromText.BackColor           = ButtonPlain;
                if (Rename.Enabled == true)
                {
                    Rename.BackColor            = ButtonPlain;
                }
                else
                {
                    Rename.BackColor            = ButtonDown;
                }
                ShowFaves.BackColor = ButtonPlain;
                ShowFavesForeImage.BackColor = ButtonPlain;
                ShowRecent.BackColor = ButtonPlain;
                ShowRecentForeImage.BackColor = ButtonPlain;
                AddFromDatabaseExtend.BackColor = ButtonPlain;
                if (Remove.Enabled == true)
                {
                    Remove.BackColor = ButtonPlain;
                }
                else
                {
                    Remove.BackColor = ButtonDown;
                }
                Step2Label.BackColor            = ButtonPlain;
            }
        
            private void AddToList_MouseEnter(object sender, EventArgs e)
            {
                Step2_On();
                AddToList.BackColor = Button_OverButton;
            }

            private void AddToList_MouseDown(object sender, MouseEventArgs e)
            {
                AddToList.BackColor = ButtonDown;
            }

            private void AddToList_MouseUp(object sender, MouseEventArgs e)
            {
                AddToList.BackColor = ButtonPlain;
            }

            private void AddFromText_MouseEnter(object sender, EventArgs e)
            {
                Step2_On();
                AddFromText.BackColor = Button_OverButton;
            }

            private void AddFromText_MouseDown(object sender, MouseEventArgs e)
            {
                AddFromText.BackColor = ButtonDown;
            }

            private void AddFromText_MouseUp(object sender, MouseEventArgs e)
            {
                AddFromText.BackColor = ButtonPlain;
            }

            private void Rename_MouseEnter(object sender, EventArgs e)
            {
                Step2_On();
                Rename.BackColor = Button_OverButton;
            }

            private void Rename_MouseDown(object sender, MouseEventArgs e)
            {
                Rename.BackColor = ButtonDown;
            }

            private void Rename_MouseUp(object sender, MouseEventArgs e)
            {
                if (Rename.Enabled == true)
                {
                    Rename.BackColor = ButtonPlain;
                }
            }

            private void Remove_MouseEnter(object sender, EventArgs e)
            {
                Step2_On();
                Remove.BackColor = Button_OverButton;
            }

            private void ShowFaves_MouseDown(object sender, MouseEventArgs e)
            {
                ShowFaves.BackColor = ButtonDown;
            }

            private void ShowFaves_MouseUp(object sender, MouseEventArgs e)
            {
                ShowFaves.BackColor = ButtonPlain;
            }

            private void ShowFaves_MouseEnter(object sender, EventArgs e)
            {
                Step2_On();
                ShowFaves.BackColor = Button_OverButton;
                ShowFavesForeImage.BackColor = Button_OverButton;
            }

            private void ShowRecent_MouseDown(object sender, MouseEventArgs e)
            {
                ShowRecent.BackColor = ButtonDown;
            }

            private void ShowRecent_MouseUp(object sender, MouseEventArgs e)
            {
                ShowRecent.BackColor = ButtonPlain;
            }

            private void ShowRecent_MouseEnter(object sender, EventArgs e)
            {
                Step2_On();
                ShowRecent.BackColor = Button_OverButton;
                ShowRecentForeImage.BackColor = Button_OverButton;
            }

            private void AddFromDatabaseExtend_MouseDown(object sender, MouseEventArgs e)
            {
                AddFromDatabaseExtend.BackColor = ButtonDown;
            }

            private void AddFromDatabaseExtend_MouseUp(object sender, MouseEventArgs e)
            {
                AddFromDatabaseExtend.BackColor = ButtonPlain;
            }

            private void AddFromDatabaseExtend_MouseEnter(object sender, EventArgs e)
            {
                Step2_On();
                AddFromDatabaseExtend.BackColor = Button_OverButton;
            }

            private void Remove_MouseDown(object sender, MouseEventArgs e)
            {
                Remove.BackColor = ButtonDown;
            }

            private void Remove_MouseUp(object sender, MouseEventArgs e)
            {
                if(Remove.Enabled == true){
                    Remove.BackColor = ButtonPlain;
                }
            }
            #endregion

            #region Step 3
            private void Step3_On()
            {
                Step3Label.BackColor            = Button_OverGroup;
                Save.BackColor                  = Button_OverGroup;
                SaveToExtendList.BackColor = Button_OverGroup;
            }

            private void MouseLeavesGroup3(object sender, EventArgs e)
            {
                Step3Label.BackColor            = ButtonPlain;
                Save.BackColor                  = ButtonPlain;
                SaveToExtendList.BackColor = ButtonPlain;
            }

            private void SaveToExtendList_MouseEnter(object sender, EventArgs e)
            {
                Step3_On();
                SaveToExtendList.BackColor = Button_OverButton;
            }

            private void SaveToExtendList_MouseDown(object sender, MouseEventArgs e)
            {
                SaveToExtendList.BackColor = ButtonDown;
            }

            private void SaveToExtendList_MouseUp(object sender, MouseEventArgs e)
            {
                SaveToExtendList.BackColor = Button_OverButton;
            }

            private void Save_MouseEnter(object sender, EventArgs e)
            {
                Step3_On();
                Save.BackColor = Button_OverButton;
            }

            private void Save_MouseDown(object sender, MouseEventArgs e)
            {
                Save.BackColor = ButtonDown;
            }

            private void Save_MouseUp(object sender, MouseEventArgs e)
            {
                Save.BackColor = Button_OverButton;
            }
            #endregion

            #region Step 4
            private void Step4_On(object sender, EventArgs e)
            {
                PrintButton.BackColor = Button_OverGroup;
                CopyToClipboard.BackColor = Button_OverGroup;
            }

            private void MouseLeavesGroup4(object sender, EventArgs e)
            {
                PrintButton.BackColor = ButtonPlain;
                CopyToClipboard.BackColor = ButtonPlain;
            }

            private void PrintButton_MouseDown(object sender, MouseEventArgs e)
            {
                PrintButton.BackColor = ButtonDown;
            }

            private void PrintButton_MouseUp(object sender, MouseEventArgs e)
            {
                PrintButton.BackColor = ButtonPlain;
            }

            private void PrintButton_MouseEnter(object sender, EventArgs e)
            {
                PrintButton.BackColor = Button_OverButton;
            }

            private void CopyToClipboard_MouseDown(object sender, MouseEventArgs e)
            {
                CopyToClipboard.BackColor = ButtonDown;
            }

            private void CopyToClipboard_MouseUp(object sender, MouseEventArgs e)
            {
                CopyToClipboard.BackColor = ButtonPlain;
            }

            private void CopyToClipboard_MouseEnter(object sender, EventArgs e)
            {
                CopyToClipboard.BackColor = Button_OverButton;
            }
            #endregion

            #region About Button
            private void AboutButton_MouseLeave(object sender, EventArgs e)
            {
                AboutButton.BackColor = ButtonPlain;
            }

            private void AboutButton_MouseEnter(object sender, EventArgs e)
            {
                AboutButton.BackColor = Button_OverButton;
            }

            private void AboutButton_MouseUp(object sender, MouseEventArgs e)
            {
                AboutButton.BackColor = Button_OverButton;
            }

            private void AboutButton_MouseDown(object sender, MouseEventArgs e)
            {
                AboutButton.BackColor = ButtonDown;
            }
            #endregion
        #endregion
        
        #endregion

        #region Other
        private void FinalBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (FinalBox.SelectedIndex == -1)
            {
                Rename.Enabled = false;
                Rename.BackColor = ButtonDown;
                Remove.Enabled = false;
                Remove.BackColor = ButtonDown;
            }
            else
            {
                Remove.Enabled = true;
                Remove.BackColor = ButtonPlain;
                Rename.Enabled = true;
                Rename.BackColor = ButtonPlain;
            }
        }
        #endregion
    }
}
